package dryworks.jsf.reflect;

import java.util.LinkedHashMap;

public class TagDefinition {
	class Attribute {
		String name;

		boolean required;

		boolean rtexprvalue;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public boolean isRequired() {
			return required;
		}

		public void setRequired(boolean required) {
			this.required = required;
		}

		public boolean isRtexprvalue() {
			return rtexprvalue;
		}

		public void setRtexprvalue(boolean rtexprvalue) {
			this.rtexprvalue = rtexprvalue;
		}
	}

	String name;

	String tagClass;

	String bodyContent;

	LinkedHashMap<String, Attribute> attributes;

	public LinkedHashMap<String, Attribute> getAttributes() {
		if (attributes == null) {
			attributes = new LinkedHashMap<String, Attribute>();
		}
		return attributes;
	}

	public void setAttributes(LinkedHashMap<String, Attribute> attributes) {
		this.attributes = attributes;
	}

	public String getBodyContent() {
		return bodyContent;
	}

	public void setBodyContent(String bodyContent) {
		this.bodyContent = bodyContent;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTagClass() {
		return tagClass;
	}

	public void setTagClass(String tagClass) {
		this.tagClass = tagClass;
	}
	
	public void addAttribute(String name, String required, String rtexprvalue) {
		addAttribute(name, required.equals("true"), rtexprvalue.equals("true"));
	}
	
	public void addAttribute(String name, boolean required, boolean rtexprvalue) {
		Attribute a = new Attribute();
		a.setName(name);
		a.setRequired(required);
		a.setRtexprvalue(rtexprvalue);
		getAttributes().put(name, a);
	}
}
